package test.nettys.nio;

import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @Author wangshaopeng
 * @Date 2021/7/14
 */
public class NioTest1 {


    public static void main(String[] args) throws IOException {
        FileInputStream inputStream = new FileInputStream("test/nettys/test1.txt");
        FileChannel channel = inputStream.getChannel();

        ByteBuffer buffer = ByteBuffer.allocate(100);
        channel.read(buffer);


        buffer.flip();

        while (buffer.hasRemaining()){
            byte b = buffer.get();
            System.out.println((char)b);
        }
        inputStream.close();

    }
}
